package com.ftwj.demo.generate.utils;

/**
*
* <p>Title: DataTypeConversionUtil</p>  
* <p>Description: SQL数据类型转化为Java数据类型</p>
* <p>Copyright: Copyright (c) 2020 </p>  
* <p>Company: 兰州飞天网景信息产业有限公司</p>    
* @author WangSLi
* @date 2020年3月6日 上午12:00:09
* @version V1.0
 */
public class DataTypeConversionUtil {
	
	public static String sqlTypeToJava(String typeName) {
        if( typeName == null || typeName.trim().length() == 0 ) return typeName;
        typeName = typeName.toLowerCase();
        switch(typeName){
            case "nvarchar":return "String";
            case "char":return "String";
            case "varchar":return "String";
            case "tinytext":return "String";
            case "text":return "String";
            case "longtext":return "String";
            case "nchar":return "String";
            case "blob":return "byte[]";
            case "enum":return "String";
            case "int":return "Integer";
            case "int unsigned":return "Long";
            case "tinyint":return "Integer";
            case "smallint":return "Integer";
            case "mediumint":return "Integer";
            case "bit":return "Boolean";
            case "bigint":return "Long";
            case "float":return "Fload";
            case "double":return "Double";
            case "decimal":return "BigDecimal";
            case "boolean":return "Boolean";
            case "id":return "Long";
            case "date":return "Date";
            case "datetime":return "Date";
            case "year":return "Date";
            case "time":return "Time";
            case "timestamp":return "Timestamp";
            case "numeric":return "BigDecimal";
            case "real":return "BigDecimal";
            case "money":return "Double";
            case "smallmoney":return "Double";
            case "image":return "byte[]";
            default:
	            System.out.println("未发现的类型,设为Object:"+typeName);
	            return "Object";
        }
	}

}
